﻿using System.Collections.Generic;

using RpcModel.Tran.Model;

namespace RpcClient.Interface
{
    /// <summary>
    /// 事务基础服务
    /// </summary>
    public interface IRpcTranService
    {
        /// <summary>
        /// 是否处在事务中
        /// </summary>
        bool IsExecTran { get; }
        /// <summary>
        /// 获取事务状态
        /// </summary>
        /// <returns></returns>
        RpcTranState GetTranState();
        /// <summary>
        /// 获取事务状态
        /// </summary>
        /// <param name="tran">事务</param>
        /// <returns>事务状态</returns>
        RpcTranState GetTranState(ICurTran tran);
        /// <summary>
        /// 手动回滚事务
        /// </summary>
        /// <param name="tran"></param>
        void Rollback(CurTranState tran);

        /// <summary>
        /// 设置事务扩展
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="extend"></param>
        void SetTranExtend<T>(T extend) where T : class;
        /// <summary>
        /// 设置事务扩展
        /// </summary>
        /// <param name="extend"></param>
        void SetTranExtend(string extend);
        /// <summary>
        /// 设置事务扩展
        /// </summary>
        /// <param name="extend"></param>
        void SetTranExtend(Dictionary<string, object> extend);
    }
}